package X20230510;

import java.util.ArrayList;
import java.util.List;

public class one {
    public static void main(String[] args) throws Exception {
        Student s1 = new Student("老王","1",21);
        Student s2 = new Student("老李","2",23);
        Student s3 = new Student("老黄","3",19);
        List<Student> list = new ArrayList<Student>();
        list.add(s1);
        list.add(s2);
        list.add(s3);

        Greet greet = new Greet("当笑容爬上你的脸庞，连太阳也会妒忌你的光芒。早！",50);
        PrintStudents printStudents = new PrintStudents(list);
        Greet goodbye =new Greet("再见",50);

        Thread t1 = new Thread(greet);
        Thread t2 = new Thread(printStudents);
        Thread t3 = new Thread(goodbye);

        t1.start();
        t2.start();
        t3.start();


    }
}
class Greet implements Runnable{
    private String sentence;
    private int times;

    public Greet(String sentence, int times) {
        this.sentence = sentence;
        this.times = times;
    }

    @Override
    public void run() {
        for (int i = 0; i < times; i++) {
            System.out.print(sentence);
        }
    }
}
class PrintStudents implements Runnable{
    private List students;

    public  PrintStudents(List students) {
        this.students = students;
    }

    @Override
    public void run() {
        students.forEach(x -> System.out.println(x));
    }
}